C# 自訂義搜尋控件


使用這個方法就可以更方便的搜尋需要的Controls

// 遞迴尋找控制項的方法
private Control FindControlByName(Control parentControl, string name)
{
    if (parentControl.Name == name)
    {
        return parentControl;
    }

    foreach (Control childControl in parentControl.Controls)
    {
        Control targetControl = FindControlByName(childControl, name);
        if (targetControl != null)
        {
            return targetControl;
        }
    }

    return null;
}
#C# #Winform







你可能感興趣的文章

[Power BI] 讀書會 #4 Analysis Services 概念(3)

[Power BI] 讀書會 #4 Analysis Services 概念(3)

Go Web 程式設計入門教學:語法基礎之流程控制(flow control)篇

Go Web 程式設計入門教學:語法基礎之流程控制(flow control)篇

來學 React 吧之七_React 實作留言板

來學 React 吧之七_React 實作留言板






留言討論